import 'package:flutter/material.dart';

// Builder构造函数
// 固定测轴水平方向子元素个数,无论如何宣战屏幕测轴子元素个数永远不变\
class GridViewBuilderWidget extends StatelessWidget {
  const GridViewBuilderWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.amber,
        title: const Text('案例-GridViewBuilder'),
      ),
      body: GridView.builder(
        gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 3,
          mainAxisSpacing: 10,
          crossAxisSpacing: 5,
          childAspectRatio: 4 / 3,
        ),
        itemCount: 30,
        itemBuilder:
            (BuildContext context, int index) => Container(
              color: Colors.red,
              alignment: Alignment.center,
              child: Text("我学习我无敌$index"),
            ),
      ),
    );
  }
}
